// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db=cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
    if (event.type == 1) {
    return await db.collection('wenjuan').where({
        openid:event.openid
    }).update({
        data:{
            name:event.name,
            date:event.date,
            wt1:event.wt1,
            wt1zl:event.wt1zl,
            wt2:event.wt2,
            wt2gx:event.wt2gx,
            wt2name:event.wt2name,
            wt3:event.wt3,
            wt3day:event.wt3day,
            wt3year:event.wt3year,
            wt4:event.wt4,
            wt4week:event.wt4week,
            wt4year:event.wt4year,
            wt4zl:event.wt4zl,
            wt5sc:event.wt5sc,
            wt5kw:event.wt5kw,
            wt5sw:event.wt5sw,
            wt5bl:event.wt5bl,
            wt5blday:event.wt5blday,
            wt5blyear:event.wt5blyear,
            wt6:event.wt6,
            wt7:event.wt7,
            wt8:event.wt8,
            wt9:event.wt9,
            wt10:event.wt10,
    }})
}
else if(event.type==2){
    return await db.collection('wenjuan2').where({
        openid:event.openid
    }).update({
        data:{
            name:event.name,
            date:event.date,
            wt1:event.wt1,
            wt2:event.wt2,
            wt3:event.wt3,
            wt4:event.wt4,
            wt5:event.wt5,
            wt6:event.wt6,
            wt7:event.wt7,
            wt8:event.wt8,
            wt9:event.wt9,
            wt10:event.wt10,
    }})
}
}
